package io.sage.modules.exam.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 学生签到积分规则枚举.
 */
public enum SignInIntegralRuleEnum {
    ONE_DAY(1, 1),
    TWO_DAY(2, 1),
    THREE_DAY(3, 2),
    FOUR_DAY(4, 2),
    FIVE_DAY(5, 3),
    SIX_DAY(6, 3),
    SEVEN_DAY(0, 6);

    // 签到天数.
    private int signInDays;
    // 积分.
    private int integral;

    // 根据签到天数获取积分.
    public static int getIntegral(Integer signInCount){
        for (SignInIntegralRuleEnum ruleEnum : SignInIntegralRuleEnum.values()){
            if (signInCount == ruleEnum.getSignInDays()){
                return ruleEnum.getIntegral();
            }
        }
        return 0;
    }

    public static List<Map<String, Object>> getList() {
        List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();
        SignInIntegralRuleEnum[] values = SignInIntegralRuleEnum.values();
        for (SignInIntegralRuleEnum questionGradeEnum : values) {
            HashMap<String, Object> hashMap = new HashMap<String, Object>();
            hashMap.put("signInDays", questionGradeEnum.getSignInDays());
            hashMap.put("integral", questionGradeEnum.getIntegral());
            returnList.add(hashMap);
        }
        return returnList;
    }

    public int getIntegral() {
        return integral;
    }

    public void setIntegral(int integral) {
        this.integral = integral;
    }

    public int getSignInDays() {
        return signInDays;
    }

    public void setSignInDays(int signInDays) {
        this.signInDays = signInDays;
    }

    SignInIntegralRuleEnum(int signInDays, int integral) {
        this.signInDays = signInDays;
        this.integral = integral;
    }
}
